package com.ztman.router.common.core;

import com.ztman.router.common.core.db.DbHelper;
import com.ztman.router.common.core.http.HttpHelper;
import com.ztman.router.common.core.prefer.PreferenceHelper;
import com.ztman.router.common.presenter.presenter_apis_data.FeedArticleListData;
import com.ztman.router.common.presenter.presenter_apis_data.LoginData;

import io.reactivex.Observable;

/**
 * @Title:DataManager
 * @Package:com.ztman.router.common.core
 * @Description:数据管理的类>>管理-LitePal数据库、管理-Preference存储、管理-http请求接口数据
 * @Auther:YJH
 * @Email:yuannunhua@gmail.com
 * @Date:2018/5/1417:12
 */
public class DataManager implements DbHelper, HttpHelper, PreferenceHelper{

    private HttpHelper mHttpHelper;
    private DbHelper mDbHelper;
    private PreferenceHelper mPreferenceHelper;


    public DataManager(HttpHelper mHttpHelper, DbHelper mDbHelper, PreferenceHelper mPreferenceHelper) {
        this.mHttpHelper = mHttpHelper;
        this.mDbHelper = mDbHelper;
        this.mPreferenceHelper = mPreferenceHelper;
    }


    @Override
    public boolean addHistoryData(String data) {
        return false;
    }

    @Override
    public boolean clearAllHistoryData() {
        return false;
    }


    @Override
    public void setLoginAccount(String accout) {
        mPreferenceHelper.setLoginAccount(accout);
    }

    @Override
    public void setLoginPassword(String password) {
        mPreferenceHelper.setLoginPassword(password);
    }

    @Override
    public String getLoginAccount() {
        return mPreferenceHelper.getLoginAccount();
    }

    @Override
    public String getLoginPassword() {
        return mPreferenceHelper.getLoginPassword();
    }

    @Override
    public void setLoginStatus(boolean isLogin) {
        mPreferenceHelper.setLoginStatus(isLogin);
    }

    @Override
    public boolean getLoginStatus() {
        return mPreferenceHelper.getLoginStatus();
    }


    @Override
    public Observable<BaseResponse<FeedArticleListData>> getFeedArticleList(int pageNum) {
        return mHttpHelper.getFeedArticleList(pageNum);
    }

    @Override
    public Observable<BaseResponse<FeedArticleListData>> getSearchList(int pageNum, String k) {
        return mHttpHelper.getSearchList(pageNum, k);
    }

    @Override
    public Observable<BaseResponse<FeedArticleListData>> getKnowledgeHierarchyDetailData(int page, int cid) {
        return mHttpHelper.getKnowledgeHierarchyDetailData(page, cid);
    }

    @Override
    public Observable<BaseResponse<LoginData>> getLoginData(String username, String password) {
        return mHttpHelper.getLoginData(username, password);
    }

    @Override
    public Observable<BaseResponse<LoginData>> getRegisterData(String username, String password, String rePassword) {
        return mHttpHelper.getRegisterData(username, password, rePassword);
    }
}
